#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

class Solution {

public:

    int firstUniqChar(string s) {

        for (int i = 0;i < s.size();i++)

        {

            size_t pos_befor = string::npos;

            size_t pos_after = string::npos;

            if (i - 1 >= 0)

                pos_befor = s.rfind(s[i], i - 1);

            if (i + 1 < s.size())

                pos_after = s.find(s[i], i + 1);

            if (pos_befor == string::npos && pos_after == string::npos)

            {

                return i;

            }

        }

        return -1;

    }

};

int main()
{
    Solution s;
    int ret =s.firstUniqChar("aabb");
    cout << ret << endl;
	return 0;
}